package xml;

import java.util.LinkedHashMap;
import java.util.Map;

import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;

public class XMLUtils {
	public static String getAttributeValue(Node node, String attributeName){
		return node.getAttributes().getNamedItem(attributeName).getNodeValue();
	}
	public static Map<String,String> getAttributes(Node node){
		NamedNodeMap attributes = node.getAttributes();
		if (attributes.getLength()==0)
			return null;
		Map<String, String> map = new LinkedHashMap<String, String>();
		for (int i = 0; i < attributes.getLength(); i++) {
			map.put(attributes.item(i).getNodeName(), attributes.item(i).getNodeValue());
		}
		return map;
	}
}
